/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-11-29
 * Time: 21:51
 */
class Solution1 {
    public String modifyString(String s) {
        char[] tem = new char[]{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
        char[] str = s.toCharArray();
        for(int i = 0 ; i < str.length ; i++){
            while(str[i] == '?'){
                for(int j = 0 ; j < tem.length ; j++){
                    if(i == 0){
                        if((str.length > 1) && (str[i+1] != tem[j])){
                            str[i] = tem[j];
                            break;
                        }else if(str.length == 1){
                            str[i] = tem[j];
                            break;
                        }else{

                        }
                    }else if(i == str.length-1){
                        if(str[i-1] != tem[j]){
                            str[i] = tem[j];
                        }else{

                        }
                    }else{
                        if((str[i+1] != tem[j]) && (str[i-1] != tem[j])){
                            str[i] = tem[j];
                            break;
                        }else{

                        }
                    }
                }
            }
        }
        String ret = "";
        for(int i = 0 ; i < str.length ; i++){
            ret += str[i];
        }
        return ret;
    }
}
class Solution1_1 {
    public String modifyString(String ss) {
        char[] s = ss.toCharArray();
        int len = s.length;
        for(int i = 0 ; i < s.length ; i++){
            if(s[i] == '?'){
                for(char ch = 'a' ; ch <= 'z' ; ch++){
                    if( (i == 0 || ch != s[i-1]) && (i == len-1 || ch != s[i+1]) ){
                        s[i] = ch;
                        break;
                    }
                }
            }

        }
        String ret = String.valueOf(s);
        return ret;
    }
}
public class Test1 {
}
